/*!
\copyright  Copyright (c) 2023 Qualcomm Technologies International, Ltd.\n
            All Rights Reserved.\n
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
*/

#ifndef LE_AUDIO_CORE_CHANNEL_EVENT_SPEC_H_
#define LE_AUDIO_CORE_CHANNEL_EVENT_SPEC_H_

#include "channel_event_spec_ids.h"
#include <bdaddr.h>
#include <connection.h>

/*! @{ */

/*! \brief The LE audio core event channel */
#define EVENT_BUS_CHANNEL_LE_AUDIO_CORE  le_audio_core_event_channel

/*! \brief The LE audio core commands for which command Complete event is sent. */
typedef enum
{
    le_audio_core_big_terminate_sync,
    le_audio_core_setup_iso_data_path,
    le_audio_core_remove_iso_data_path,
} le_audio_core_cmd_complete_event_t;

/*! \brief The LE audio core event that are sent. */
typedef enum
{
    le_audio_core_disconnection_complete,
    le_audio_core_cis_disconnection_complete,
    le_audio_core_enhanced_connection_complete,
    le_audio_core_connection_update_complete,
    le_audio_core_cis_request,
    le_audio_core_cis_established,
    le_audio_core_command_complete,
    le_audio_core_big_sync_established,
    le_audio_core_big_sync_lost,
    le_audio_core_big_info_report_received,
} le_audio_core_event_t;
    
typedef enum
{
    bredr_link,
    ble_link,
    cis_link,
} acl_link_type_t;

typedef struct
{
    uint8_t status ;
    uint16_t connection_handle;
    hci_status reason;
    acl_link_type_t type;
} LE_AUDIO_CORE_DISCONNECTION_COMPLETE_T;

typedef LE_AUDIO_CORE_DISCONNECTION_COMPLETE_T LE_AUDIO_CORE_CIS_DISCONNECTION_COMPLETE_T;

typedef struct
{
    uint8_t subevent_code;
    hci_status status;
    uint16_t conn_handle;
    uint8_t role;
    uint8_t Peer_Address_Type;
    bdaddr peer_address;
    bdaddr local_res_pvt_addr;
    bdaddr peer_res_pvt_addr;
    uint16_t conn_interval;
    uint16_t conn_latency;
    uint16_t supervision_Timeout;
    uint8_t max_clok_accuracy;
} LE_AUDIO_CORE_ENHANCED_CONNECTION_COMPLETE_T;

typedef struct
{
    uint8_t subevent_code;
    hci_status status;
    uint16_t conn_handle;
    uint16_t conn_interval;
    uint16_t conn_latency;
    uint16_t supervision_Timeout;
} LE_AUDIO_CORE_CONNECTION_UPDATE_COMPLETE_T;

typedef struct
{
    uint8_t subevent_code;
    hci_status status;
    uint16_t conHandle;
    uint32_t cigSyncDelay;
    uint32_t cisSyncDelay;
    uint32_t transportLatencyC2P;
    uint32_t transportLatencyP2C;
    uint8_t phyC2P;
    uint8_t phyP2C;
    uint8_t nse;
    uint8_t bnC2P;
    uint8_t bnP2C;
    uint8_t ftC2P;
    uint8_t ftP2C;
    uint16_t maxPduC2P;
    uint16_t maxPduP2C;
    uint16_t isoInterval;
} LE_AUDIO_CORE_CIS_ESTABLISHED_T;

typedef struct
{
    uint8 subevent_code;
    uint16 acl_conn_Handle;
    uint16 cis_conn_Handle;
    uint8 cig_id;
    uint8 cis_id;
} LE_AUDIO_CORE_CIS_REQUEST_T;

typedef struct
{
    le_audio_core_cmd_complete_event_t command;
    hci_status status;
    uint16_t conn_handle;
} LE_AUDIO_CORE_COMMAND_COMPLETE_T;

/**
 * @brief Structure representing the established BIG synchronization.
 */
typedef struct
{
    uint16 status;              /*!< Status of the synchronization */
    uint32 transport_latency;   /*!< Max time to tx SDUs of all BISes */
    uint16 max_pdu;             /*!< Maximum size of an PDU */
    uint16 iso_interval;        /*!< ISO interval */
    uint8 phy;                  /*!< PHY used */
    uint8 nse;                  /*!< Number of sub events */
    uint8 bn;                   /*!< Burst number */
    uint8 pto;                  /*!< Pre transmission offset */
    uint8 irc;                  /*!< Repeated count of retransmission */
    uint8 big_handle;           /*!< Host identifier of BIG */
    uint8 num_bis;              /*!< Number of BISes synchronized */
    uint16 *bis_handles;        /*!< Connection handle of BISes */
} le_audio_core_big_sync_established_t;

typedef struct
{
    uint16 reason;
    uint8 big_handle;           /*!< Host identifier of BIG */
} le_audio_core_big_sync_lost_t;

typedef struct
{
    uint16 sync_handle;         /*!< Sync handle of the PA */
    uint8 num_bis;              /*!< Number of BISes in BIG */
    uint8 nse;                  /*!< Number of sub events */
    uint16 iso_interval;        /*!< iso interval */
    uint8 bn;                   /*!< Burst number */
    uint8 pto;                  /*!< Pre transmission offset */
    uint8 irc;                  /*!< repeated count of retransmission */
    uint16 max_pdu;             /*!< Maximum size of an PDU */
    uint32 sdu_interval;        /*!< Interval of Periodic SDUs*/
    uint16 max_sdu;             /*!< Maximum size of an SDU */
    uint8 phy;                  /*!< PHY for transmission */
    uint8 framing;              /*!< framed or unframed data */
    uint8 encryption;           /*!< data encryption status */
} le_audio_core_big_info_report_received_t;

/*! @} */

#endif /* LE_AUDIO_CORE_CHANNEL_EVENT_SPEC_H_ */